<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'north'" class="center">
        <input type="hidden" name="id" id="targetId"/>
        <input type="hidden" id="source" value="2"/>
        <div class="webmap">
            <p class="webmaptip">当前位置:</p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">借款管理</a>
            <p class="webmaptip">></p>
            <a href="javascript:;" class="easyui-link" data-options="plain:true">还款完成的项目 </a>
        </div>
        <div class="querybycon">
            <form id="query">
                <div class="queryinfo">
                    <div>借款类型 <input class="easyui-combobox" name="productid"
                                     data-options="url:'/dictionary/loanType?all=true'"></div>
                    <div class="db">还款时间 <input name="startTime" class="easyui-datetimebox">-<input name="endTime"
                                                                                                    class="easyui-datetimebox">
                    </div>
                    <div>用户名<input type="text" name="telephone" maxlength="11"/></div>
                    <div>真实姓名<input type="text" name="bdrealname" minlength="2" maxlength="6"></div>
                    <div>借款编号<input type="text" name="loanNumber"></div>
                    <div class="query">
                        <a id="querybtn" href="javascript:;" class="easyui-linkbutton  "
                           data-options="iconCls:'fa fa-search'"></a>
                    </div>
                </div>
            </form>
        </div>
        <div class="querybtn">
            <a href="javascript:;" class="easyui-linkbutton info see"
               data-options="iconCls:'fa fa-search'">查看</a>
            <a href="javascript:;" class="easyui-linkbutton info record"
               data-options="iconCls:'fa fa-search'">投资记录</a>
            <a href="javascript:;" class="easyui-linkbutton info payBackPlan"
               data-options="iconCls:'fa fa-search'">还款计划</a>
            <a href="javascript:;" class="easyui-linkbutton info payBackPlanDetail"
               data-options="iconCls:'fa fa-search'">投资还款明细</a>
        </div>
        <div class="separator"></div>
    </div>
    <div data-options="region:'center'" class="center">
        <table id="list"></table>
    </div>
</div>
<div id="detailsWin" class="easyui-window"></div>
<script type="text/javascript" src="/static/fresco-2.2.1-light/js/fresco/fresco.js"></script>
<link rel="stylesheet" type="text/css" href="/static/fresco-2.2.1-light/css/fresco/fresco.css"/>
<script type="text/javascript">
    var listUrl = "/paybackPlan/payBackFinish"; //还款完成的项目
    var investListUrl = "/page/project/loaninvest.html"; //投资记录页面
    var payBackPlanUrl = "/page/project/paybackPlanList.html";//还款计划页面
    var payBackPlanDetailUrl = "/page/project/paybackPlanDetails.html";//投资还款明细页面
    var findTarget = "/target/findTargetById";//一条数据
    var detailUrl = "/page/project/targetmsg.html";  // 跳转详情页面
    var columns = [[{
        field: 'id',
        checkbox: true,
    }, {
        field: 'loanNumber',
        title: '借款编号',
    }, {
        field: 'telephone',
        title: '用户名',
    }, {
        field: 'bdrealname',
        title: '姓名',
    }, {
        field: 'productid',
        title: '借款类型',
        formatter: function (value, row, index) {
            if (value) {
                if (value == '103') {
                    return '车辆周转贷';
                } else if (value == '104') {
                    return '房产周转贷';
                } else if (value == '105') {
                    return '个人消费贷';
                } else if (value == '106') {
                    return '个体经营贷';
                } else if (value == '107') {
                    return '农业贷';
                } else if (value == '108') {
                    return '企业经营贷';
                }
            }
        }
    }, {
        field: 'htje',
        title: '借款金额(元)',
        align: 'right',
        formatter: function (value, row, index) {
            if (value) {
                return value.formatMoney();
            }
            return value;
        }
    }, {
        field: 'htqx',
        title: '借款期限(月)',
        align: 'center'
    }, {
        field: "hkqs",
        title: "期数"
    }, {
        field: 'yhkr',
        title: '还款截止时间',
    }, {
        field: 'endDate',
        title: '实际还款时间',
    }]];
    list.init({url: listUrl, columns: columns});

    //投资记录
    $(".record").click(function () {
        var rows = $("#list").datagrid('getChecked');
        if (rows.length != 1) {
            $.messager.alert('操作提示', '请选择一行数据', 'info');
            $("#list").datagrid('uncheckAll');
            return false;
        } else {
            $("#targetId").val(rows[0].id);
            $("#win").window({
                width: 900,
                height: 700,
                title: "投资记录"
            }).window("open").window("center").window("refresh", investListUrl);
        }
    });
    //还款计划
    $(".payBackPlan").click(function () {
        var rows = $("#list").datagrid('getChecked');
        if (rows.length != 1) {
            $.messager.alert('操作提示', '请选择一行数据', 'info');
            $("#list").datagrid('uncheckAll');
            return false;
        } else {
            $("#targetId").val(rows[0].id);
            $("#win").window({
                width: 900,
                height: 700,
                title: "还款计划"
            }).window("open").window("center").window("refresh", payBackPlanUrl);
        }
    });
    $(".payBackPlanDetail").click(function () {
        var rows = $("#list").datagrid('getChecked');
        if (rows.length != 1) {
            $.messager.alert('操作提示', '请选择一行数据', 'info');
            $("#list").datagrid('uncheckAll');
            return false;
        } else {
            $("#win").window({
                width: 1300,
                height: 700,
                title: "投资还款明细"
            }).window("open").window("center").window("refresh", payBackPlanDetailUrl);
        }
    });
    //查看按钮
    $(".see").click(function () {
        var rows = $("#list").datagrid('getChecked');
        if (rows.length != 1) {
            $.messager.alert('操作提示', '请选择一行数据', 'info');
            $("#list").datagrid('uncheckAll');
            return false;
        } else {
            $("#detailsWin").window({
                width: 900,
                height: 700
            }).window("open").window("center").window("refresh", detailUrl);

        }

    });
</script>
